package com.leoman.dao;

import com.leoman.entity.UserPraise;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 用户点赞or踩视频
 * Created by Administrator on 2016/10/18 0018 下午 3:04.
 */
public interface UserPraiseDao extends JpaRepository<UserPraise, Integer>, JpaSpecificationExecutor<UserPraise> {

    @Query("select a from UserPraise a where a.appUser.id = ?1 and a.video.id = ?2 and a.type = ?3")
    UserPraise iFindOneByUserIdAndVideoIdAndType(Integer userId, Integer videoId, Integer type);

    @Query("select a from UserPraise a where a.video.id = ?1 and a.type = ?2")
    List<UserPraise> iFindListByVideoIdAndType(Integer videoId, Integer type);

    @Query("select a from UserPraise a where a.video.id = ?1")
    List<UserPraise> iFindListByVideoId(Integer videoId);
}